# Project name

PROJ = client

# LIB_DEP = plat_ai plat_common plat_vqe plat_log plat_thread pthread plat_mem akaudiofilter m plat_dbg plat_osal
# LIB_DEP += dl

#OS_TYPE为1，则编译出静态库，否则编译出可执行文件
ifneq ($(OS_TYPE), 0)
    TARGET = lib$(PROJ).a
else
    TARGET = $(PROJ)
endif

#添加前缀“-l”
LIBS = $(addprefix -l, $(LIB_DEP))

#TOPDIR为Application文件夹
TOPDIR 	?= $(shell pwd)/../..

# Flags

#去以下目录寻找头文件
INCLUDE    =	-I. \
		# -I../../include_inner \
		# -I../../include \
		# -I../include \
		# -I$(EXT_LIB_DIR)/include \

#Locations

#需要编译源文件的目录
SRCDIR += .

#去源文件的目录找出所有.c文件
CSRCS += $(foreach d, $(SRCDIR), $(wildcard $d/*.c))

#将刚刚找到的.c文件系列替换成.o文件系列
COBJS += $(patsubst %.c, %.o, $(CSRCS))

#库路径Application/lib
LIB_DIR = $(TOPDIR)/lib

#链接规则
LD_FLAGS = -Xlinker "-(" $(LIBS) -Xlinker "-)"  -L$(LIB_DIR)

ifeq ($(OS_TYPE), 0)
LD_FLAGS += -L$(EXT_LIB_DIR)
endif

#编译安装规则，单独的.c文件按照rules.mk编译出.o
.PHONY: all target install clean

all: $(COBJS)
ifneq ($(OS_TYPE), 0)
	$(AR) -rsv $(TARGET)  $(COBJS)
	@cp -r $(TARGET) $(TOPDIR)/lib
else
	$(CC) $(COBJS) $(LD_FLAGS) -o $(TARGET)
	$(STRIP) $(TARGET)
endif

install:
ifeq ($(OS_TYPE), 0)
	@cp -f $(TARGET) $(SAMPLE_INSTALL_DIR)
else
	@cp -f $(TARGET) $(PLATFORM_INSTALL_DIR)/lib
endif

clean : 
	$(RM) $(COBJS) $(TARGET)

ifndef RULES_MK_FILE
RULES_MK_FILE=$(TOPDIR)/../rules.mk
endif


# Rules
include $(RULES_MK_FILE)
